<template>
  <div class="my-counter">
    <button type="button" @click="sum.goods_count--" class="btn btn-light">-</button>
    <input type="number" v-model="sum.goods_count" ref="text" class="form-control inp" />
    <button type="button" @click="sum.goods_count++" class="btn btn-light">+</button>
  </div>
</template>

<script>
export default {
  props: {
    sum: {
      type: Object,
      required: true
    }
  },
  watch: {
    sum: {
      deep: true,
      handler() {
        if (this.sum.goods_count < 1) this.sum.goods_count = 1
      }
    }
  }
}
</script>

<style lang="less" scoped>
.my-counter {
  display: flex;
  .inp {
    width: 65px;
    text-align: center;
  }
  input[type='number']::-webkit-inner-spin-button,
  input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  input[type='number'] {
    -moz-appearance: textfield;
  }
  .btn,
  .inp {
    transform: scale(0.9);
  }
}
</style>
